package com.itheima.test;



import com.itheima.domain.Student1;

import java.util.TreeSet;

public class ComparableDemo {
    public static void main(String[] args) {
        TreeSet<Student1> treeSet=new TreeSet<Student1>();
        Student1 student=new Student1("yi",5);
        Student1 student1=new Student1("er",7);
        Student1 student2=new Student1("san",3);
        Student1 student3=new Student1("si",3);
        Student1 student4=new Student1("wu",8);

        treeSet.add(student);
        treeSet.add(student1);
        treeSet.add(student2);
        treeSet.add(student3);
        treeSet.add(student4);

        for (Student1 s:treeSet){
            System.out.println(s.getName()+" "+s.getAge());

        }
    }
}
